import 'package:fijkplayer/fijkplayer.dart';
import 'package:flutter/material.dart';
import 'package:my_demo_flutter/my_base_lib/base_lib.dart';

class FijkPlayerTestPage extends StatefulWidget {
  static String routeName = "/FijkPlayerTestPage";

  const FijkPlayerTestPage({Key? key}) : super(key: key);

  @override
  _FijkPlayerTestPageState createState() => _FijkPlayerTestPageState();
}

class _FijkPlayerTestPageState extends BaseWidgetState<FijkPlayerTestPage> {
  late FijkPlayer player1;
  late FijkPlayer player2;
  late FijkPlayer player3;

  @override
  Widget build(BuildContext context) {
    String url1 = "https://media.w3.org/2010/05/sintel/trailer.mp4";
    String url2 = "http://vfx.mtime.cn/Video/2021/07/10/mp4/210710122716702150.mp4";
    String url3 = "http://mirror.aarnet.edu.au/pub/TED-talks/911Mothers_2010W-480p.mp4";

    player1 = FijkPlayer()..setDataSource(url1, autoPlay: true);
    player2 = FijkPlayer()..setDataSource(url2, autoPlay: true);
    player3 = FijkPlayer()..setDataSource(url3, autoPlay: true);
    return Scaffold(
      appBar: AppBar(title: Text("FijkPlayer多视频同时播放")),
      body: Column(
        children: [
          FijkView(
            height: 200,
            player: player1,
            fit: FijkFit.fill,
          ),
          FijkView(
            height: 200,
            player: player2,
          ),
          Expanded(
              child: FijkView(
            player: player3,
            fit: FijkFit.fill,
          ))
        ],
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
    player1.release();
    player2.release();
    player3.release();
  }
}
